//
//  JuQingTableViewCell.m
//  TableView
//
//  Created by Carl_fang on 15/3/28.
//  Copyright (c) 2015年 Carl_fang. All rights reserved.
//

#import "JuQingTableViewCell.h"

@interface JuQingTableViewCell()



@end

@implementation JuQingTableViewCell

-(void)setDetailModel:(DetailModel *)detailModel
{
    self.stroyLabel.text = detailModel.pt;
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        

        _stroyLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 280, 70)];
        //_stroyLabel.backgroundColor = [UIColor redColor];
        _stroyLabel.font = [UIFont systemFontOfSize:15];
        _stroyLabel.numberOfLines = 0;
        [self.contentView addSubview:_stroyLabel];
        
        _allTextBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [_allTextBtn setTitle:@"...更多..." forState:UIControlStateNormal];
        _allTextBtn.frame = CGRectMake(50, CGRectGetMaxY(_stroyLabel.frame), 200, 30);
        [self.contentView addSubview:_allTextBtn];
        
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        
        [center addObserver:self selector:@selector(changeFrame:) name:@"btn" object:nil];
        
    }
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return self;
}


- (void)changeFrame:(NSNotification *)no
{
    
    NSLog(@"111%s",__func__);
    CGFloat height = [[no.userInfo objectForKey:@"height"] floatValue];
    
    _stroyLabel.frame = CGRectMake(20, 10, 280, height);
    //_stroyLabel.contentMode = UIViewContentModeScaleAspectFit;
    //_allTextBtn.frame = CGRectMake(50, CGRectGetMaxY(_stroyLabel.frame), 200, 30);
    _allTextBtn.hidden = YES;
    NSLog(@"QQQQQQQQQQQQ%f", height);
    
    
}

+ (CGFloat)heightForString:(NSString *)str
{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName, nil];
    CGRect strRect = [str boundingRectWithSize:CGSizeMake(280, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return strRect.size.height;
    
}

//计算文本高度
//+ (CGFloat)heightForString:(NSString *)str{
//    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16], NSFontAttributeName, nil];
//    
//    CGRect bounds = [str boundingRectWithSize:CGSizeMake(300, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
//    
//    return bounds.size.height;
//}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
